package heima.lm.oschina.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import heima.lm.oschina.R;
import heima.lm.oschina.adapter.GeneralVpPagerAdapter;

/**
 * Created by herenxue on 2017/4/1.
 * 综合的Fragment
 */

public class GeneralFragment extends Fragment {

    @BindView(R.id.tab_general)
    public TabLayout mTabLayout;

    @BindView(R.id.vp_general)
    public ViewPager mViewPager;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //注入view
        View view = inflater.inflate(R.layout.fragment_general, container, false);
        //ButterKnife绑定fragment
        ButterKnife.bind(this, view);
        // ViewPager 与 FragmentStatePagerAdapter
        GeneralVpPagerAdapter mVpPagerAdapter = new GeneralVpPagerAdapter(getChildFragmentManager());
        mViewPager.setAdapter(mVpPagerAdapter);
        // TabLayout和ViewPager的结合使用
        mTabLayout.setupWithViewPager(mViewPager);
        return view;
    }


}
